package com.ruoyi.web.controller.kzgl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kzgl.domain.TbKzglDgkzsq;
import com.ruoyi.kzgl.service.ITbKzglDgkzsqService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 电柜授权用户Controller
 * 
 * @author ruoyi
 * @date 2023-11-11
 */
@RestController
@RequestMapping("/kzgl/dgkzsq")
public class TbKzglDgkzsqController extends BaseController
{
    @Autowired
    private ITbKzglDgkzsqService tbKzglDgkzsqService;

    /**
     * 查询电柜授权用户列表
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgkzsq:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbKzglDgkzsq tbKzglDgkzsq)
    {
        startPage();
        List<TbKzglDgkzsq> list = tbKzglDgkzsqService.selectTbKzglDgkzsqList(tbKzglDgkzsq);
        return getDataTable(list);
    }

    /**
     * 导出电柜授权用户列表
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgkzsq:export')")
    @Log(title = "电柜授权用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbKzglDgkzsq tbKzglDgkzsq)
    {
        List<TbKzglDgkzsq> list = tbKzglDgkzsqService.selectTbKzglDgkzsqList(tbKzglDgkzsq);
        ExcelUtil<TbKzglDgkzsq> util = new ExcelUtil<TbKzglDgkzsq>(TbKzglDgkzsq.class);
        util.exportExcel(response, list, "电柜授权用户数据");
    }

    /**
     * 获取电柜授权用户详细信息
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgkzsq:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(tbKzglDgkzsqService.selectTbKzglDgkzsqByID(ID));
    }

    /**
     * 新增电柜授权用户
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgkzsq:add')")
    @Log(title = "电柜授权用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbKzglDgkzsq tbKzglDgkzsq)
    {
        return toAjax(tbKzglDgkzsqService.insertTbKzglDgkzsq(tbKzglDgkzsq));
    }

    /**
     * 修改电柜授权用户
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgkzsq:edit')")
    @Log(title = "电柜授权用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbKzglDgkzsq tbKzglDgkzsq)
    {
        return toAjax(tbKzglDgkzsqService.updateTbKzglDgkzsq(tbKzglDgkzsq));
    }

    /**
     * 删除电柜授权用户
     */
    @PreAuthorize("@ss.hasPermi('kzgl:dgkzsq:remove')")
    @Log(title = "电柜授权用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(tbKzglDgkzsqService.deleteTbKzglDgkzsqByIDs(IDs));
    }
}
